<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8" />
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="viewport" content="width=device-width, initial-scale=1.0" />
        <title>Document</title>
    </head>
    <body>
        <script>
            /* 
            只要是子串或者是子数组，一定能暴力破解，即找出所有的子数组和子串再判断逻辑
            
            */
            var countSubstrings = function (s) {
                let result = []
                for (let i = 0; i < s.length; i++) {
                    for (let j = i; j < s.length; j++) {
                        let str = s.slice(i, j + 1)
                        if (isPali(str)) {
                            result.push(str)
                        }
                    }
                }
                return result
                function isPali(str) {
                    let left = 0
                    let right = str.length - 1
                    while (left < right) {
                        if (str[left] == str[right]) {
                            left++
                            right--
                        } else {
                            return false
                        }
                    }
                    return true
                }
            }
        </script>
    </body>
</html>
